package com.mengtian_tech.smart_lab.service.system;

import java.util.ArrayList;
import java.util.List;

import com.mengtian_tech.smart_lab.entity.system.TSDepart;
import com.mengtian_tech.smart_lab.entity.system.TSUser;

import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrgnizationServiceImpl implements OrgnizationService {

	@Autowired
	SystemService systemService;
	
	@Override
	public List<TSUser> findParentOrgUserList(String orgId) {
		List<TSUser> result = new ArrayList<>();
		TSDepart depart =  systemService.getEntity(TSDepart.class, orgId);
		TSDepart parentDepart = depart.getTSPDepart();
		if(parentDepart == null){
			return result;
		}
		
		result = systemService.findByQueryString(" select a.tsUser from TSUserOrg a where a.tsDepart.id = ? ",
				new Object[]{parentDepart.getId()});
		
		return result;
	}

}
